﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FCMGAAI
{
    public partial class Form1 : Form
    {
        FCM1 FCM = new FCM1();
        GA1 algen;
        String ErrMsg = "";
        String FilePath = "";
        bool isFileLoaded = false;
        bool isFCMRunned = false;
        bool isGARunned = false;
        public Form1()
        {
            InitializeComponent();
            openFileDialog1.Filter = "txt files(*.txt)|*.txt|All Files(*.*)|*.*";
        }


        private void loadFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                FilePath = openFileDialog1.FileName;
                if (FCM.ProcessInputFile(FilePath, ref ErrMsg))
                {
                    MessageBox.Show("Preprocessing Berhasil");
                    isFileLoaded = true;
                    
                }
                else
                {
                    MessageBox.Show(ErrMsg);
                }
            }
        }

        private void fCMToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (isFileLoaded)
            {
                FCMForm FcmForm = new FCMForm(ref FCM);
                FcmForm.MdiParent = this;
                FcmForm.Show();
                isFCMRunned = FCM.isRunned;
            }
            else
            {
                MessageBox.Show("corpus harus di load dulu, pilih menu preprocessing");
            }
            
        }

        private void fCMGAToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            if (isFileLoaded && ShareVariable.IsFCMRunned)
            {
                algen = new GA1(ref FCM);
                GAForm GAForm = new GAForm(ref algen);
                GAForm.MdiParent = this;
                GAForm.Show();
                isGARunned = algen.isRunned;
                
            }
            else
            {
                MessageBox.Show("FCM Harus Dijalankan terlebih dahulu");
            }
        }

        private void validasiToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (isFileLoaded && ShareVariable.IsFCMRunned && ShareVariable.isGARunned)
            {
                Validasi Vd = new Validasi(FCM);
                ValidasiForm VDform = new ValidasiForm(Vd);
                VDform.MdiParent = this;
                VDform.Show();
            }
            else
            {
                MessageBox.Show("FCM & FCMGA Harus Dijalankan terlebih dahulu");
            }
        }

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Program ini dibuat oleh : \n Mirza Galih K (5112201002) \n Muhammad Alif Irsyadi (5112201029) \n M Yusuf (5112201030) \n ");
        }
    }
}
